<template>
  <el-drawer
    :title="title"
    :visible.sync="visible"
    direction="rtl"
    :before-close="handleClose">
    <div class="drawer_body">
      <div class="item" v-for="item in infoData">
        <div class="title">{{item.lable}}</div>
        <div class="content">
          <div class="child" v-for="child in item.child">
            <div class="child_title">{{child.title}}</div>
            <div class="child_info">{{child.info}}</div>
          </div>
        </div>
      </div>
    </div>
  </el-drawer>
</template>

<script lang="ts">
import { Component, Emit, Prop, Vue, Watch } from 'vue-property-decorator'

@Component({
  name: 'BasicDrawer'
})
export default class extends Vue {
  @Prop({ default: '' }) private title!: string
  @Prop({ default: '' }) private infoData!: object
  @Prop({ default: true }) private visible!: boolean
  @Prop({ default: false }) private loading!: boolean
  @Emit('handleClose') handleClose() {}

  @Watch('visible')
  private changeVal(val: any) {
    console.log(val)
    console.log(this.$scopedSlots)
  }
}
</script>

<style lang="scss" scoped>
@import '../../styles/_elementVariables.scss';
::v-deep .el-drawer__container.el-drawer__open {
  top: 50px;
  height:calc(100% - 50px);

  .el-drawer.rtl {
    width: 28% !important;

    .el-drawer__header {
      height: 50px;
      margin: 0;
      border-bottom: 1px solid $--color-assist-divider;
      padding: 0 15px 0 20px;

      span {
        display: block;
        width: 100%;
        height: 100%;
        line-height: 50px;
        font-size: $--title-font-size;
        color: $--color-assist-title;
      }

      .el-dialog__close.el-icon.el-icon-close {
        font-size: 18px;
        line-height: 50px;
        color: $--color-assist-value-text;
      }
    }
  }

  .drawer_body {
    width: 100%;
    height: auto;
    padding: 0 20px 20px 20px;

    .item {
      .title {
        height: 60px;
        font-size: 14px;
        color: #333333;
        line-height: 60px;
      }
      .content {
        padding:0 20px;

        .child {
          width: 100%;
          height: 30px;
          line-height: 30px;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          .child_title {
            min-width: 70px;
            font-size: 12px;
            color: #999999;
            text-align: right;
            margin-right: 20px;
          }

          .child_info {
            font-size: 12px;
            color: #333333;
            text-align: left;
          }
        }
      }
    }

  }

  .drawer_body>div {
    border-bottom: 1px solid $--color-assist-divider;
    padding-bottom: 20px;
  }

  .drawer_body>div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }
}
</style>
